package com.dfbz.demo01;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo06_小练习 {
    public static void main(String[] args) throws ParseException {

        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入您的生日: ");
//         生日
        String birthday = scanner.nextLine();
//        String birthday = "2002-10-15";


        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date birthdayDate = sdf.parse(birthday);
        long birthdayTime = birthdayDate.getTime();

        // 现在的时间
        Date nowDate = new Date();
        long nowTime = nowDate.getTime();

        long liveTime = nowTime - birthdayTime;

        System.out.println("您一共活了【" + (liveTime / 1000 / 60 / 60 / 24) + "】天");

    }
}
